package com.ds.client.screen;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.ClickListener;
import com.badlogic.gdx.scenes.scene2d.ui.Image;

/**
 * win game screen, shows win game information
 */
public class WinScreen implements Screen{

	InitGame game;
	Stage winStage;
	Image winGameScreen;
	Image reviveBtn;
	
	public WinScreen(InitGame initGame){
		game = initGame;
	}
	@Override
	public void dispose() {
		winStage.clear();
		
	}

	@Override
	public void hide() {
		
	}

	@Override
	public void pause() {
		
	}

	@Override
	public void render(float arg0) {
		Gdx.gl.glClearColor(255, 255, 255, 255);
		Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
		winStage.draw();
		
	}

	@Override
	public void resize(int arg0, int arg1) {
		
	}

	@Override
	public void resume() {
		
	}

	@Override
	public void show() {
		winStage = new Stage(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(),
				false);
		initWinGame();
	}
	
	public void initWinGame() {
		winGameScreen = new Image(new TextureAtlas(
		"res/resultScreen/winGameScreen.pack").findRegion("YouWin"));
		reviveBtn = new Image(new TextureAtlas(
		"res/revive.pack").findRegion("BUTTONS_restart"));
		setImagePosition(reviveBtn, 375, 50);
		setImagePosition(winGameScreen, 0, 0);
		// switch to chooseScreen
		reviveBtn.setClickListener(new ClickListener() {
			@Override
			public void click(Actor actor, float arg1, float arg2) {
				dispose();
				game.setScreen(game.getChooseScreen());
			}
		});
		winStage.addActor(winGameScreen);
		winStage.addActor(reviveBtn);
		Gdx.input.setInputProcessor(winStage);
	}
	
	public void setImagePosition(Image image, float x, float y) {
		image.x = x;
		image.y = y;
	}

}
